Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added external link icon #4757

Closed
wants to merge 12 commits into from
Closed

feat: Added external link icon #4757

wants to merge 12 commits into from

Conversation

lavr001
Copy link
Contributor

@lavr001 lavr001 commented Nov 16, 2023

Description of changes

Added external link icon when isExternal prop is true

Before:

Link_before

After:

Link_after

Issue #4515 , if available

Description of how you validated changes

Checklist

  • Have read the Pull Request Guidelines
  • PR description included
  • Relevant documentation is changed or added (and PR referenced)
  • yarn test passes and tests are updated/added
  • No side effects or sideEffects field updated

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@lavr001 lavr001 requested a review from a team as a code owner November 16, 2023 19:54
Copy link

changeset-bot bot commented Nov 16, 2023

⚠️ No Changeset found

Latest commit: 5309237

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

packages/react/src/primitives/Link/Link.tsx Outdated Show resolved Hide resolved
packages/ui/src/theme/css/component/link.scss Outdated Show resolved Hide resolved
packages/ui/src/theme/css/component/link.scss Outdated Show resolved Hide resolved
Comment on lines 2 to 3
import { classNames } from '@aws-amplify/ui';
import { ComponentClassName } from '@aws-amplify/ui';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be a single import line

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved, there are two import lines for the same package still. In the future, please refrain from resolving a conversation until the feedback has been addressed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are two import lines for the same package across multiple primitives, I'll make sure to make it one line when done with other updates on this PR.

@@ -25,6 +24,7 @@ const LinkPrimitive: Primitive<LinkProps, 'a'> = (
{...rest}
>
{children}
{isExternal && <IconBoxArrowUpRight />}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few things here:

  • Prefer ternary returning null if isExternal is falsy to prevent this expression from evaluating to false
  • How do i hide the icon?
  • How do i position the icon to the left of the children?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Updated to use a ternary operator
  2. You can hide the icon when isExternal prop is set to false (default)
  3. It's important to start with a word that indicates the action that results if customers click the link. Putting an icon at the beginning of the link disrupts the readability of the link quite massively, therefore it is a common convention to put icons after the actual link text

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can hide the icon when isExternal prop is set to false (default)

Sure, but what if the link is external and i don't want the icon?

It's important to start with a word that indicates the action that results if customers click the link. Putting an icon at the beginning of the link disrupts the readability of the link quite massively, therefore it is a common convention to put icons after the actual link text

  1. What abt RTL languages?
  2. This response is an opinion on the usage of the Link component but does not address the actual question

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call on RTL languages. I'll work on adding a position prop, so devs can control the icon position

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to create a position prop since the direction='rtl' can be set in the ThemeProvider and it will automatically applied to the Link component
Screenshot 2023-12-04 at 4 00 24 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lavr001 The above question is still unanswered:

You can hide the icon when isExternal prop is set to false (default)

Sure, but what if the link is external and i don't want the icon?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calebpollman Are you suggesting having a new prop called hasIcon that would be visible only when the link is external, so users can control if they want the icon or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calebpollman Added new prop hideIcon, so now if the Link is external you have an option to show/hide the icon. Also added a new prop linkIconPosition, so you can position the icon left or right to the Link
Screenshot 2024-01-09 at 2 54 22 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this icon come from and why is it not centered like the other icons?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't typically use icons from the external libraries, I just looked online for a SVG path that forms the icon. I've added align-items: center to make the icon vertically aligned, but I can take another look to see what else could be done to make it more vertically centered

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using a specific icon set from material, so we should be consistent and use the same one for this too. @dbanksdesign Do you remember which version we were using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked SVG icons from material and they didn't really have a specific external link icon, so I grabbed another SVG

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this SVG taken from and what was the reasoning used in choosing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply googled svg path for external icon, since we don't usually pull in icons from an external source. Not sure what do you mean by reasoning. Are you suggesting some other approaches here?

@lavr001 lavr001 requested a review from reesscot December 5, 2023 00:06
Copy link
Member

@calebpollman calebpollman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerned overall with the approach taken here.

Rendering an icon by default for any Link components that have an external link could break customers layouts that have added an icon themselves, nor are we providing a means to override the icon or hide it. Blocking this until all feedback is addressed and the PR no longer contains breaking changes

Comment on lines 2 to 3
import { classNames } from '@aws-amplify/ui';
import { ComponentClassName } from '@aws-amplify/ui';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unresolved, there are two import lines for the same package still. In the future, please refrain from resolving a conversation until the feedback has been addressed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this SVG taken from and what was the reasoning used in choosing it?

@@ -25,6 +24,7 @@ const LinkPrimitive: Primitive<LinkProps, 'a'> = (
{...rest}
>
{children}
{isExternal && <IconBoxArrowUpRight />}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lavr001 The above question is still unanswered:

You can hide the icon when isExternal prop is set to false (default)

Sure, but what if the link is external and i don't want the icon?

@lavr001 lavr001 requested a review from calebpollman January 4, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants